const db = require('../DBcofig/DBConnection')
module.exports = {
    getAppointmentMedical(req, res) {
        let { id, radio, startDate, endDate } = req.query;
        // console.log(req.query);
        let sql = "SELECT * FROM patientspep AS a,attendance_card AS b,medicalplan AS c WHERE a.cardId=b.card_id AND a.medical_ID=c.medicalID"
        let arr = []
        if (id != undefined) {
            sql += ` and cardId= ?`
            arr.push(id)
        }
        if (radio != undefined && radio > 0) {
            sql += ` and patients_status = ?`
            arr.push(radio)
        }
        if (startDate != undefined && endDate != undefined) {
            sql += ` and patients_TJDate >=? and patients_TJDate <?`
            arr.push(startDate, endDate)
        }
        console.log(sql, arr);
        db.dbconfig(res, sql, arr, function(data) {
            // console.log(data, "啦啦啦");
            if (data != null) {
                res.send({
                    code: 200,
                    msg: '查询成功',
                    data: data
                });
            } else {
                res.send({
                    code: 404,
                    msg: '查询失败',
                });
            }

        })
    },
}